package com.zsk;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;

import com.zsk.controller.TestFilter;

/**
 * main
 * https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-tomcat/2.0.9.RELEASE
 * @author keke
 * @date 2020/05/06
 */
@SpringBootApplication
@EnableScheduling
public class Application extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(Application.class);
    }

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

    @Bean
    public FilterRegistrationBean<TestFilter> testFilterRegistration() {
        FilterRegistrationBean<TestFilter> registration = new FilterRegistrationBean<TestFilter>(new TestFilter());
        registration.addUrlPatterns("/*");
        registration.setName("TestFilter");
        return registration;
    }

}
